﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hi_Baidu.Enum.User;
using System.Windows.Forms;
using System.Drawing;
using NetMeeting_Server.Config;

namespace Hi_Baidu.Entry.Base
{
    /// <summary>
    ///     当前登陆用户相关信息
    /// </summary>
    public class User
    {
        #region 用户字段

        private int _MULIT_COUNT;
        /// <summary>
        ///     本机多开数量
        /// </summary>
        public int MULIT_COUNT
        {
            get { return _MULIT_COUNT; }
            set { _MULIT_COUNT = value; }
        }

        private int _TALK_PORT;
        /// <summary>
        ///     聊天端口
        /// </summary>
        public int TALK_PORT
        {
            get { return _TALK_PORT; }
            set { _TALK_PORT = value; }
        }
        /// <summary>
        ///     音频端口
        /// </summary>
        private int _VOICE_PORT;

        public int VOICE_PORT
        {
            get { return _VOICE_PORT; }
            set { _VOICE_PORT = value; }
        }
        private int _VIDEO_PORT;
        /// <summary>
        ///     视频端口
        /// </summary>
        public int VIDEO_PORT
        {
            get { return _VIDEO_PORT; }
            set { _VIDEO_PORT = value; }
        }
        private int _LISTEN_PORT;
        /// <summary>
        ///     监听端口
        /// </summary>
        public int LISTEN_PORT
        {
            get { return _LISTEN_PORT; }
            set { _LISTEN_PORT = value; }
        }
        private int _TRANSFER_FILE_PORT;
        /// <summary>
        ///     文件传送端口
        /// </summary>
        public int TRANSFER_FILE_PORT
        {
            get { return _TRANSFER_FILE_PORT; }
            set { _TRANSFER_FILE_PORT = value; }
        }

        private String _SESSION_CODE = "";
        /// <summary>
        ///    自身基础会话码
        /// </summary>
        public String SESSION_CODE
        {
            get { return _SESSION_CODE; }
            set { _SESSION_CODE = value; }
        }

        private Dictionary<String, byte[]> _DIC_USERINFO;
        /// <summary>
        ///     用户自身信息字典
        /// </summary>
        public Dictionary<String, byte[]> DIC_USERINFO
        {
            get { return _DIC_USERINFO; }
            set { _DIC_USERINFO = value; }
        }

        #endregion

        /// <summary>
        /// 用户上线状态
        /// </summary>
        public ONLIN_STATE USER_ONLINE_STATE = ONLIN_STATE.OFFLINE;
        /// <summary>
        ///    任务栏图标句柄
        /// </summary>
        public NotifyIcon NI = new NotifyIcon();
        /// <summary>
        ///     在线时的任务栏图标
        /// </summary>
        public Icon ICON_ONLINE = new Icon(@"../Icon/ICON_LL/460.ico", new System.Drawing.Size(16, 16));
        /// <summary>
        ///     隐身时的任务栏图标
        /// </summary>
        public Icon ICON_HIDDEN = new Icon(@"../Icon/ICON_LL/503.ico", new System.Drawing.Size(16, 16));
        /// <summary>
        ///     忙碌时的任务栏图标
        /// </summary>
        public Icon ICON_BUSY = new Icon(@"../Icon/ICON_LL/504.ico", new System.Drawing.Size(16, 16));
        /// <summary>
        ///     离开时的任务栏图标
        /// </summary>
        public Icon ICON_AWAY = new Icon(@"../Icon/ICON_LL/502.ico", new System.Drawing.Size(16, 16));
        /// <summary>
        ///     下线时任务栏图标
        /// </summary>
        public Icon ICON_OFFLINE = new Icon(@"../Icon/532.ico", new Size(16, 16));
        /// <summary>
        ///     配置文件读取类
        /// </summary>
        private ConfigInfo CI = new ConfigInfo();

        /// <summary>
        ///     探测当前可以使用的客户端端口
        /// </summary>
        public void DetectPort()
        {
            MULIT_COUNT = 10;
            TALK_PORT = Hi_Baidu.Net.MutilInstance.MutilRun.DirectPort
                (
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "TalkPort")),
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "TalkPort")) + MULIT_COUNT,
                    Hi_Baidu.Net.MutilInstance.MutilRun.PROTOCOL.UDP
                );
            /// <summary>
            ///     音频端口
            /// </summary>
            VOICE_PORT = Hi_Baidu.Net.MutilInstance.MutilRun.DirectPort
                (
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "VoicePort")),
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "VoicePort")) + MULIT_COUNT,
                     Hi_Baidu.Net.MutilInstance.MutilRun.PROTOCOL.UDP
                );
            /// <summary>
            ///     视频端口
            /// </summary>
            VIDEO_PORT = Hi_Baidu.Net.MutilInstance.MutilRun.DirectPort
                (
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "VideoPort")),
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "VideoPort")) + MULIT_COUNT,
                    Hi_Baidu.Net.MutilInstance.MutilRun.PROTOCOL.UDP
                );
            /// <summary>
            ///     监听端口
            /// </summary>
            LISTEN_PORT = Hi_Baidu.Net.MutilInstance.MutilRun.DirectPort
                (
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "TalkPort")),
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "TalkPort")) + MULIT_COUNT,
                    Hi_Baidu.Net.MutilInstance.MutilRun.PROTOCOL.UDP
                );
            /// <summary>
            ///     文件传送端口
            /// </summary>
            TRANSFER_FILE_PORT = Hi_Baidu.Net.MutilInstance.MutilRun.DirectPort
                (
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "TransferFilePort")),
                    int.Parse(CI.GetXmlContent("../Config/Config.xml", "ServerConfig", "TransferFilePort")) + MULIT_COUNT,
                    Hi_Baidu.Net.MutilInstance.MutilRun.PROTOCOL.UDP
                );
        }
    }
}
